<?php 
	//$this->defaultTest();
	$ssFilter 			= $this->arrParam['ssFilter'];
	$action_link 		= $this->baseUrl($this->currentController . '/filter/type/order');
	$lbluser_name 		= $this->cmsLinkSort('User name', 'u.username', $ssFilter,
							$this->imgUrl . '/icon', $action_link);
	$lblStatus 			= $this->cmsLinkSort('Status', 'u.status', $ssFilter,
							$this->imgUrl . '/icon', $action_link);
	$lblEmail 			= $this->cmsLinkSort('Email', 'u.email', $ssFilter,
							$this->imgUrl . '/icon', $action_link);
	$lblRegisterDate	= $this->cmsLinkSort('Registed', 'u.register_date', $ssFilter,
							$this->imgUrl . '/icon', $action_link);
	$lblGroup 			= $this->cmsLinkSort('Group', 'group_name', $ssFilter,
							$this->imgUrl . '/icon', $action_link);
	$lblID 				= $this->cmsLinkSort('ID', 'u.userid', $ssFilter,
							$this->imgUrl . '/icon', $action_link);
	
	//--------------------CREATE GROUP SELECTBOX-----------------------//
	
	$linkSlbGroup = $this->baseUrl($this->currentController . '/filter/type/group');
	$options = $this->sblGroup;
	$sblGroup = $this->formSelect('group_id', $ssFilter['group_id'],
									array('onchange' => "OnSubmitForm('" . $linkSlbGroup . "')"), $options);
	$selectGroup = 'Group: ' . $sblGroup;
	
	
	// Create search area
	$keywords 			= $this->formText('keywords', $ssFilter['keywords'], array('class' => 'txtshort'));
	$linkSearch 		= $this->baseUrl($this->currentController . '/filter/type/search/key/1');
	$btnSearch 			= $this->formButton('Search-now', 'Search-now', array('onClick'=>"OnSubmitForm('" . $linkSearch . "')"));
	$linkResetSearch 	= $this->baseUrl($this->currentController . '/filter/type/search/key/0');
	$btnResetSearch 	= $this->formButton('Clear-keywords', 'Clear', array('onClick'=>"OnSubmitForm('" . $linkResetSearch . "')"));
	
	$strSearch = $keywords . ' ' . $btnSearch . ' ' . $btnResetSearch;
	
?>
<div id="content-box">
            <div class="border">
                <div class="padding">

                    <form name="appForm" method="post" action="">
                        <?php echo $this->render('user/toolbar/index.php');?>
						<div class="clr"></div>
						<?php echo $this->render('user/sublink/index.php');?>

                        <!-- BEGIN: CONTENT -->
                        <div id="element-box">
                            <div class="t">
                                <div class="t">
                                    <div class="t"></div>
                                </div>
                            </div>
                            <div class="m">
                                <!-- BEGIN: ELEMENT BOX -->
                                <div id="filters">
                                	<div style="float: left;"><?php echo $strSearch;?></div>
                                	<div style="float: right;"><?php echo $selectGroup;?></div>
                                	<div class="clr"></div>
                                </div>

                                <!-- Area 4: In du lieu lay tu database -->
                                <table class="adminlist">
                                    <thead>
                                        <tr>
                                            <th width="43" ><input type="checkbox" name="checkbox" id="checkbox" onClick="checkedAll()"></th>
                                            <th><?php echo $lbluser_name;?></th>
                                            <th width="89"><?php echo $lblStatus;?></th>
                                            <th width="83"><?php echo $lblEmail;?></th>
                                            <th width="86"><?php echo $lblRegisterDate;?></th>						
                                            <th width="77"><?php echo $lblGroup;?></th>
                                            <th width="90">Control</th>
                                            <th width="34"><?php echo $lblID;?></th>
                                        </tr>
                                    </thead>
									
									<?php 
										foreach ($this->Items as $key => $val){
											$id 				= $val['userid'];
											$user_name 			= $val['username'];
											$email 				= $val['email'];
											$register_date 		= $val['register_date'];
											$group_name 		= $val['group_name'];
											
											$group_acp 		= $val['group_acp'];
											if($group_acp == 1){
												$linkActive = $this->baseUrl($this->currentController . '/acp/type/0/id/' . $id);
												$group_acp = $this->cmsIconButton('Access', $this->imgUrl . '/icon/active.png', $linkActive);
											}else{
												$linkActive = $this->baseUrl($this->currentController . '/acp/type/1/id/' . $id);
												$group_acp = $this->cmsIconButton('No Access', $this->imgUrl . '/icon/inactive.png', $linkActive);
											}
											
											$status 		= $val['status'];
											if($status == 1){
												$linkStatus = $this->baseUrl($this->currentController . '/status/type/0/id/' . $id);
												$status = $this->cmsIconButton('Active', $this->imgUrl . '/icon/active.png', $linkStatus);
											}else{
												$linkStatus = $this->baseUrl($this->currentController . '/status/type/1/id/' . $id);
												$status = $this->cmsIconButton('Inactive', $this->imgUrl . '/icon/inactive.png', $linkStatus);
											}
											
											$members 		= $val['members'];
											$order 			= $this->formText('order[' . $val['id'] . ']', $val['order'], array('style' => 'width: 30px; text-align: center;'));
											$linkInfo 		= $this->baseUrl($this->currentController . '/info/id/' . $id);
											$btnInfo 		= $this->cmsIconButton('View Item', $this->imgUrl . '/icon_info.png', $linkInfo);
											$linkEdit 		= $this->baseUrl($this->currentController . '/edit/id/' . $id);
											$btnEdit 		= $this->cmsIconButton('Edit Item', $this->imgUrl . '/icon_edit.png', $linkEdit);
											$linkDelete		= $this->baseUrl($this->currentController . '/delete/id/' . $id);
											$btnDelete 		= $this->cmsIconButton('Delete Item', $this->imgUrl . '/icon_del.png', $linkDelete);
											
											$strIconButton 	= $btnInfo . ' ' . $btnEdit . ' ' . $btnDelete;
											$cid 			= $this->formCheckbox('cid[]', $val['id']);
											
									?>
                                    <tr class="even">						
                                        <td align="center"><?php echo $cid;?></td>
                                        <td align="left"><?php echo $user_name;?></td>
                                        <td align="center"><?php echo $status;?></td>
                                        <td align="center"><?php echo $email;?></td>
                                        <td align="center"><?php echo $register_date;?></td>
                                        <td align="center"><?php echo $group_name;?></td>
                                        <td align="center"><?php echo $strIconButton;?></td>
                                        <td align="center"><?php echo $id;?></td>
                                    </tr>
                                    
                                    <?php }?>
                                    <!-- BEGIN: PAGINATION (FOOT) -->
                                    <tfoot>
                                        <tr>
                                            <td colspan="9">
                                                <div class="container">
                                                    <div class="pagination">
                                                    	<?php 
                                                    		$currentUrl = $this->baseUrl($this->currentController . '/index');
                                                    		echo $this->paginationControl($this->paginator, 'Sliding', 'pagination.phtml', array('currentUrl'=>$currentUrl));
                                                    	?>
                                                        <div class="limit"></div>
                                                    </div>
                                                </div>
                                            </td>
                                        </tr>					
                                    </tfoot>				<!-- END: PAGINATION (FOOT) -->
                                </table>
                                <!-- Area 4: In du lieu lay tu database - End -->

                                <!-- END: ELEMENT BOX -->	
                              <div class="clr"></div>
                            </div>
                            <div class="b">
                                <div class="b">
                                    <div class="b"></div>
                                </div>
                            </div>
                        </div>
                        <!-- END: 	CONTENT -->
                    </form>


                    <div class="clr"></div>
                </div>
                <div class="clr"></div>
            </div>
        </div>